package com.campus.controller;

import com.campus.common.CampusWall;
import com.campus.common.Result;
import com.campus.entity.Posts;
import com.campus.entity.Users;
import com.campus.service.PostService;
import com.campus.utils.SnowFlakeUtil;
import com.campus.utils.TokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class PostController {
    @Autowired
    private TokenUtils tokenUtils;
    @Autowired
    private PostService postService;
    /**
     * 上传帖子
     * @param post
     * @param token
     * @return
     */
    @PostMapping("/post/create")
    public Result createPost(@RequestBody Posts post,@RequestHeader(CampusWall.CAMPUS_TOKEN) String token){
        Result result = postService.createPost(post, token);

        return result;
    }
}
